TOP_DIR = $(CURDIR)/

GSOAP_ROOT = $(TOP_DIR)/../gsoap-2.8/gsoap

CC = gcc -g -O2 #-DWITH_OPENSSL -DHAVE_PTHREAD_H
INCLUDE = -I$(GSOAP_ROOT) -I../
SERVER_OBJS = onvif.o soapC.o soapServer.o stdsoap2.o duration.o
SERVER_SSL_OBJS = onvif.o soapServer.o stdsoap2.o duration.o

HEADERS = $(wildcard *.h)

all: onvif.h gen server

server: $(SERVER_OBJS)
		$(CC) -o webserver $(SERVER_OBJS) $(INCLUDE) -lpthread

serverssl: $(SERVER_SSL_OBJS)
		$(CC) -o webserverssl $(SERVER_SSL_OBJS) $(INCLUDE) -lpthread -lssl -lcrypto

onvif.h:
	wsdl2h -c -t $(GSOAP_ROOT)/typemap.dat -o onvif.h \
		http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl \
		http://www.onvif.org/onvif/ver10/events/wsdl/event.wsdl \
		http://www.onvif.org/onvif/ver10/display.wsdl \
		http://www.onvif.org/onvif/ver10/deviceio.wsdl \
		http://www.onvif.org/onvif/ver20/imaging/wsdl/imaging.wsdl \
		http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl \
		http://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl \
		http://www.onvif.org/onvif/ver10/receiver.wsdl \
		http://www.onvif.org/onvif/ver10/recording.wsdl \
		http://www.onvif.org/onvif/ver10/search.wsdl \
		http://www.onvif.org/onvif/ver10/network/wsdl/remotediscovery.wsdl \
		http://www.onvif.org/onvif/ver10/replay.wsdl \
		http://www.onvif.org/onvif/ver20/analytics/wsdl/analytics.wsdl \
		http://www.onvif.org/onvif/ver10/analyticsdevice.wsdl \
		http://www.onvif.org/ver10/actionengine.wsdl \
		http://www.onvif.org/onvif/ver10/schema/onvif.xsd \
		http://www.w3.org/2006/03/addressing/ws-addr.xsd

#http://www.onvif.org/ver10/pacs/accesscontrol.wsdl \
#http://www.onvif.org/ver10/pacs/doorcontrol.wsdl \

gen:
	soapcpp2 -cxT onvif.h -I$(GSOAP_ROOT)/import:$(GSOAP_ROOT):$(GSOAP_ROOT)/custom:.
	mv soapTester.c onvif.c
	cp $(GSOAP_ROOT)/custom/duration.* ./
	cp $(GSOAP_ROOT)/stdsoap2.c ./
	cp $(GSOAP_ROOT)/stdsoap2.h ./


clean:
	rm -rf *.o *.nsmap soap* onvif.h onvif stdsoap2.* duration.*

